<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
$plugin_name = $_RQ['basicname'] ? $_RQ['basicname'] : '';
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('setting',$postdata);
		exi('设置成功');
	}
	$item=$this->plugin_setting('setting');
	$plugins = $this->plugins();
	$hdps =array(
		array('title'=>'首页','picurl'=>'../core/resource/images/diy/default/banner-1.jpg','action'=>'index'),
		array('title'=>'全部','picurl'=>'../core/resource/images/diy/default/banner-2.jpg','action'=>'allplugins'),
	);
	$item['hdps'] = !empty($item['hdps']) ? $item['hdps'] : $hdps;
	$bankuai1 =array(
			array('title'=>'送礼神器','picurl'=>'../addons/jy_weishop_9kuai/resource/images/men01.png','linkurl'=>custom_url('jy_weishop/shop.groups/')),
			array('title'=>'全球美食','picurl'=>'../addons/jy_weishop_9kuai/resource/images/men02.png','linkurl'=>''),
			array('title'=>'优选到家','picurl'=>'../addons/jy_weishop_9kuai/resource/images/men03.png','linkurl'=>''),
			array('title'=>'优选国际','picurl'=>'../addons/jy_weishop_9kuai/resource/images/men04.png','linkurl'=>''),
			array('title'=>'新品尝鲜','picurl'=>'../addons/jy_weishop_9kuai/resource/images/men05.png','linkurl'=>''),
	);
	$pics01 =array(
			array('picurl'=>'../addons/jy_weishop_9kuai/resource/images/pics01.png','linkurl'=>''),
			array('picurl'=>'../addons/jy_weishop_9kuai/resource/images/pics02.png','linkurl'=>''),
	);
	$banner =array(
			array('picurl'=>'../addons/jy_weishop_9kuai/resource/images/banner01.png','linkurl'=>''),
			array('picurl'=>'../addons/jy_weishop_9kuai/resource/images/banner02.png','linkurl'=>''),
	);
	$item['bankuai1'] = !empty($item['bankuai1']) ? $item['bankuai1'] : $bankuai1;
	$item['bankuai2'] = !empty($item['bankuai2']) ? $item['bankuai2'] : $bankuai2;
	$item['pics01'] = !empty($item['pics01']) ? $item['pics01'] : $pics01;
	$item['pics02'] = !empty($item['pics02']) ? $item['pics02'] : $pics02;
	$item['banner'] = !empty($item['banner']) ? $item['banner'] : $banner;
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'index'),
		array('title'=>'百宝箱','icon'=>'icon-all','action'=>'allplugins'),
		array('title'=>'订单','icon'=>'icon-manageorder','action'=>'jy_weishop/order.list'),
		array('title'=>'我的','icon'=>'icon-wo1','action'=>'jy_weishop/member.index'),
	);
	$item['footernav'] = !empty($item['footernav']) ? $item['footernav'] : $footernav;
	$cube =array(
		array('title'=>'首页','image'=>'../core/resource/images/diy/default/cube-1.jpg','action'=>'index'),
		array('title'=>'全部','image'=>'../core/resource/images/diy/default/cube-2.jpg','action'=>'allplugins'),
		array('title'=>'订单','image'=>'../core/resource/images/diy/default/cube-3.jpg','action'=>'jy_weishop/order.list'),
		array('title'=>'我的','image'=>'../core/resource/images/diy/default/cube-4.jpg','action'=>'jy_weishop/member.index'),
	);
	$item['cube'] = !empty($item['cube']) ? $item['cube'] : $cube;
	$return['groups']=pdo_getall('jy_weishop_goods_group',array('uniacid'=>$_SESSION['uniacid'],'parentid'=>$item['group_id']),array('id','title'));
	foreach($item['banner'] as &$v){
		if($v['group_id']){
			$v['group_title']=pdo_getcolumn('jy_weishop_goods_group',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['group_id']),'title');
		}
	}
	$return['item'] = $item;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'choose_many','name'=>'huodonggoods01','title'=>'活动01-商品','op'=>'choosegoods','choose_title'=>'选择商品','help'=>'选择多个活动商品'),
					array('type'=>'choose_many','name'=>'huodonggoods02','title'=>'活动02-商品','op'=>'choosegoods','choose_title'=>'选择商品','help'=>'选择多个活动商品'),
					array('type'=>'choose_many','name'=>'huodonggoods03','title'=>'活动03-商品','op'=>'choosegoods','choose_title'=>'选择商品','help'=>'选择多个活动商品'),
				)
			),
			array(
				'title'=>'幻灯片',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'hdps',
							'add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>''),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								)
						)
					)
			),
			array(
							'title'=>'板块导航1',
							'list'=>array(
									array('type'=>'array','name'=>'bankuai1','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'picurl','title'=>'导航图片'),
										array('type'=>'string','name'=>'linkurl','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'picurl','title'=>'导航图片'),							
										array('type'=>'link','name'=>'linkurl','title'=>'导航链接'),
									)
								),
							)
				),
				array(
							'title'=>'板块导航2',
							'list'=>array(
									array('type'=>'array','name'=>'bankuai2','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'picurl','title'=>'导航icon'),
										//array('type'=>'color','name'=>'color','title'=>'导航颜色'),
										array('type'=>'string','name'=>'linkurl','title'=>'导航链接'),
										array('type'=>'radio','name'=>'is_install','title'=>'是否显示','options'=>'is_installs'),								
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'picurl','title'=>'导航icon'),
										//array('type'=>'color','name'=>'color','title'=>'导航颜色'),										
										array('type'=>'link','name'=>'linkurl','title'=>'导航链接'),
										array('type'=>'switch','name'=>'is_install','title'=>'是否显示'),
									)
								),
							)
			),
			array(
				'title'=>'首页banner图',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'banner',
							'add_tip'=>'添加一张banner图',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'banner图图片'),
									array('type'=>'string','name'=>'linkurl','title'=>'banner图链接'),
									array('type'=>'string','name'=>'group_title','title'=>'绑定商品分类（首页会展示对应的商品）'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'banner图图片','help'=>''),
									array('type'=>'string','name'=>'linkurl','title'=>'banner图链接'),
									array('name'=>'group_id','title'=>'绑定分类','type'=>'select','options'=>'groups','help'=>'只能绑定主分类下的二级分类！'),
									
								)
						)
					)
			),
			array(
				'title'=>'首页活动图块01',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'pics01',
							'add_tip'=>'添加一张图块',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图块图片'),
									array('type'=>'string','name'=>'linkurl','title'=>'图块链接'),									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图块图片','help'=>''),
									array('type'=>'string','name'=>'linkurl','title'=>'图块链接'),
								)
						)
					)
			),
			array(
				'title'=>'首页活动图块02',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'pics02',
							'add_tip'=>'添加一张图块',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图块图片'),
									array('type'=>'string','name'=>'linkurl','title'=>'图块链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'图块图片','help'=>''),
									array('type'=>'string','name'=>'linkurl','title'=>'图块链接'),
									
								)
						)
					)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
							array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'string','name'=>'icon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'string','name'=>'icon','title'=>'导航图标','help'=>'图标，例如：icon-shouye'),							
										array('type'=>'string','name'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
					'title'=>'魔方设置',
					'list'=>array(
						array('type'=>'array','name'=>'cube','add_tip'=>'添加一个魔方',
								'list'=>array(
									array('type'=>'image','name'=>'image','title'=>'图片'),	
									array('type'=>'string','name'=>'url','title'=>'链接'),
								),
								'details'=>array(
									array('type'=>'image','name'=>'image','title'=>'图片'),
									array('type'=>'string','name'=>'url','title'=>'链接'),
								)
						),
					)
				),
				array(
					'title'=>'分享设置',
					'list'=>array(
						array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
						array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
						array('type'=>'text','title'=>'分享描述','name'=>'share_desc'),
					)
				),
				array(
					'title'=>'开关设置',
					'list'=>array(
						array('type'=>'switch','title'=>'关闭顶部搜索','name'=>'issearch'),
						array('type'=>'switch','title'=>'关闭幻灯片','name'=>'ishdps'),
						array('type'=>'switch','title'=>'关闭板块导航1','name'=>'isbankuai1'),
						array('type'=>'switch','title'=>'关闭板块导航2','name'=>'isbankuai2'),
						array('type'=>'switch','title'=>'关闭魔方','name'=>'iscube'),
						array('type'=>'switch','title'=>'关闭底部菜单','name'=>'isfooternav'),
						array('type'=>'switch','title'=>'关闭分享','name'=>'isshare'),
					)
				),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='chooseplugins'){
	$list = pdo_getall('core_plugins',array('hide'=>0),array('id','style','name','title','image','description'),'id');
	if($list){
		foreach($list as $k=>&$item){
			if(!check_permission($item['name'])){
				unset($list[$k]);
			}else{
				$item['plugininfo'] = array('name'=>$item['name'],'title'=>$item['title'],'description'=>$item['description']);
			}
			
		}
	}
	$return['list']=$list;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}
if($_RQ['op']=='choosegoods'){
	$setting=$this->plugin_setting('setting');
	$list = pdo_getall('jy_weishop_goods',array('pcate'=>$setting['group_id'],'uniacid'=>$_SESSION['uniacid']),array('id','title','image','price'));
	$return['list']=$list;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
			array('name'=>'image','title'=>'图片','type'=>'image'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'id','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}

